package com.mindspore.vision.base;

import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;

import com.mindspore.vision.R;

public abstract class BaseActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstance) {
        super.onCreate(savedInstance);
        setContentView(getLayout());
        setStatusBarTextColor();
        init();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    protected abstract void init();

    public abstract int getLayout();

    public void setStatusBarTextColor() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            int color = window.getStatusBarColor();
            if (color == 0) {
                window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                window.getDecorView().setBackgroundColor(getColor(R.color.white));
            }
        }
    }
}
